﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StyleMVVM.DependencyInjection;
using StyleMVVM.View;
using StyleMVVM.ViewModel;
using Windows.Storage;
using Windows.Storage.Pickers;

namespace ExampleApp.ViewModels
{
	public class MessageBoxAndFilePickerViewModel : BaseViewModel
	{
		private string messageText = "Message Text";
		private string fileName = "None";

		public string MessageText
		{
			get { return messageText; }
			set { SetProperty(ref messageText, value); }
		}

		[Import]
		public IMessageBoxService MessageBoxService { get; set; }

		public void OpenMessageBox()
		{
			MessageBoxService.Show(MessageText, "This is the Title");
		}

		public string FileName
		{
			get { return fileName; }
			set { SetProperty(ref fileName, value); }
		}

		[Import]
		public IFilePickerService FilePicker { get; set; }

		public async void OpenFilePicker()
		{
			StorageFile storageFile = await FilePicker.PickFileAsync(PickerLocationId.DocumentsLibrary, ".txt");

			if(storageFile != null)
			{
				FileName = storageFile.DisplayName;
			}
			else
			{
				FileName = "Canceled";
			}

		}
	}
}
